#!/usr/bin/perl


@text = (	"/*LICENSE_BEGIN\n",   # DO NOT CHANGE THIS LINE
		" * ******************************************************************\n",
		" * Copyright 2006 by the Dainamite Robocup-Team at the\n",
		" * DAI-Labor, TU-Berlin (www.dai-labor.de)\n",
		" * \n",
		" * Members of Dainamite are:\n",
		" * Holger Endert\n",
		" * Robert Wetzker\n",
		" * Thomas Karbe\n",
		" * Axel Heßler\n",
		" * Philippe Bütter\n",
		" * Felix Brossmann\n", 
		" * \n",
		" * Licensed under the GNU GPL (General Public License) Free Software \n",
		" * License, Version 2. You may use this file only in compliance with \n",
		" * the License. You may obtain a copy of the License at:\n",
		" * \n",
		" * http://www.fsf.org/licensing/licenses/gpl.txt\n",
		" * ******************************************************************\n",
		########################	
		"LICENSE_END*/\n"); # DO NOT CHANGE THIS LINE
		
 changeDir('.');


###SUBS####

### fakultaet(Zahl)
# bestimme die Fakultaet einer Zahl
sub changeDir{
  my $dir=$_[0];

 # Verzeichnis lesen
opendir(DIR, $dir);
	my @dateien = readdir(DIR);
closedir(DIR);

# Addition oder Rekursion fuer alle gelesenen
foreach my $datei (@dateien) {
	next if ( ($datei eq '.') || ($datei eq '..'));
	my $pfadtotal = "$dir/$datei";
	if(-d $pfadtotal) {
		changeDir($pfadtotal);	
	} 
	if ($datei =~ /.java/) {

		print $pfadtotal."\n";

		open(INFILE, $pfadtotal);
			my @lines = <INFILE>;
		close(INFILE);
		
		open(OUTFILE, ">".$pfadtotal);
			print OUTFILE @text;
			my $license = 0;
			
			foreach $line (@lines) {
				if($line =~ /LICENSE_BEGIN/) {
					$license = 1;
				}
				if($license == 0) {
					print OUTFILE $line;
				}
				if($line =~ /LICENSE_END/) {
					$license = 0;
				}
			}
		close(INFILE);
		
	}
}

}		